package com.tobby.demo.jmxdemo;

import java.lang.management.ManagementFactory;

import javax.management.MBeanServer;
import javax.management.ObjectName;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MessageEngineAgent {

	private static Logger LOG = LoggerFactory.getLogger(MessageEngineAgent.class);

	public void start() {
		MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
		try {
			ObjectName mxBeanName = new ObjectName("com.tobby.demo:type=MessageEngine");
			MessageEngineMXBean mxBean = new MessageEngine();
			mbs.registerMBean(mxBean, mxBeanName);
		}
		catch (Exception e) {
			LOG.error(e.getMessage(), e);
		}
	}

}
